Yes you can. The better question is SHOULD you?
marry him
Yes, but ability to marry has nothing to do with immigration status.
You can marry someone of that nationality.
You can marry a person who is here illegally anytime in every state. At this time there are no laws forbidding one to marry someone like that.
No, they are here illegally and will be until they get a green card or register as a u.s. citizen
An undocumented immigrant
tough. that already happened to someone i know. they are both hiding from the police and no he cannot stay. when the police know both of you might go to jail. you may marry him but maybe somewhere else.
Moscow or Madagascar
No it will not be easier to get a green card. And how did they illegally marry? If they were issued a marriage license, and they did not lie on the application, they are legally married.
If you entered illegally, then no, marriage would not make you legal. You would need to file and win a I-601 waiver at the US embassy of your home country.
Although it would not effect their rights to marridge, they would risk deportation unless marrying citizens of the US, and so it is not advisable.
There are many kinds of illegal marriages. One common kind is bigamy, the crime of marrying someone when still married to another. The process (not recommended) of illegally marrying your boyfriend would be to first marry someone else and then, without divorcing that husband, marry your boyfriend. Such a bigamous marriage is likely illegal in any U.S. state at any age.