Is it unethical to get paid for the work and time invested in thesis?
That is totally fine, many people do a master thesis in an official cooperation with a company. University hasn't hired you for your studies, and the diploma is not your "payment".
Who might be in trouble is your professor and his company, if he hasn't cleared this with the university officials. Because he has a contract with the university, and they have some rights to your results, because they provided the lab, provided your professor, etc.
I think it's fine to get paid by the university for doing your research. No one's going to fault you for your work having real world applications. I know many students who have summer jobs that overlap with their research interests and no one blinks an eye when they finish up their research and then go to work for companies that benefit from it. Ideally, you'd probably want to get a job for a company that does work in your area.
That being said, it's probably unethical to double-dip and get paid for the same work twice. Depending upon your school's policies, you also might have to list the company as a conflict of interest on some internal document.