If you have a Swedish passport, it seems unusual to me that you would be denied an ESTA. This probably indicates that there is something about your profile that raises a red flag to the US immigration system, so they want to review your case in-depth with a full visitor visa application. Since they are already suspicious for some unknown reason, I do not think anyone here can give you a reasonable estimate of how likely it is for you to obtain a visitor visa.
That said, there is one definite red flag in your question: "And if I get there, can I apply for a green card to stay with my wife or not?" If the US immigration officials suspect that you might think of applying for a green card after you arrive in the United States, they would most likely deny your visa not because they think you are a dangerous person, but because they might suspect that you are trying to stay longer than the duration of a visitor visa. The correct process is to apply for an immigrant visa before you go to the United States. They would almost always deny visitor visas to people whom they suspect are trying to stay longer than the normal duration for a visitor.
Probably the best way to increase your chances of getting a visitor visa approved is to sincerely plan to visit and then go back in the normal time limit, and then show that you have everything in place for that (e.g., a stable job in Sweden that is expecting you to come back after your vacation). Without such evidence, they might deny your visitor visa.