Its because in Morocco in particular like certain other countries, there is a high instance of marriage fraud with young men marrying foreign women as a means for them to get out of their country to either Europe or North America where opportunities are better. Immigration officials are very wary and want to see lots of proof that this is not the case.
An online relationship that leads to marriage on the very first visit will definitely raise suspicions. Even more so if no one from your family or any friends will be there. Also, in Morocco, weddings are a very big deal. A rushed quickie wedding with none of the standard cultural fanfare which includes special preparations, clothing, celebrations, and the involvement of his family members will also lead them to believe the relationship may not be genuine. Keep in mind they are not wondering if it is genuine to you, they will be well aware you are head over heels in love with him, have spent a lot of time online, and are fully invested in the relationship. Its him and his intentions that they will focus on.
Being completely honest with you, as hard as I know this distance is for you, the best way to do this is to go, meet him, meet his family, go on lots of outings, take lots of pictures, have a wonderful time and show you are a normal couple, progressing in a normal way towards getting married. A proposal if you must, just make sure you document it with pictures, have family acknowledgement, maybe an engagement dinner or something special to mark it because later when you apply they want to know about this and if there was nothing, again its a concern. Engagements are also a big deal in their culture.
Enjoy Morocco! Let him take you out sight seeing, get more familiar with your husbands country!
If you try to do the marriage thing on the first trip you will be so consumed with running around to get all the requirements and then it will be over, wont even have much time to enjoy being married together! It will be time to come home and you will miss out on that. (Although on a side note, you might have to be chaperoned and wont be able to stay with him alone in a hotel or room as an unmarried couple...the law and his faith wont allow it. It happens all the time though, so it just depends on how devout he and his family are and how likely authorities are to try and enforce it).
Then, come home, bask in the glow of your even more strengthened love...after meeting and knowing in your heart that this is the man you want to spend the rest of your life with, start preparing and planning for your wedding. It will be so exciting if you and him have the chance to actually plan and eventually have the wedding you always dreamed of! Get friends and family involved with helping you pick out your dress, talk about it in emails, texts, social media whatever (this stuff will be so good to have as proof later, especially if no one from your side is able to make the trip to be at your wedding).
Then go back and marry him the right way, with lots of family and friends, pictures, a big special Moroccan approved affair. Fill out and sign the application forms there while you are with him so you don't have to be sending it all back and forth, take it home with you, compile all your proofs and everything you need to send with it, and apply.
Its more work and a little more time but it will greatly improve your chances, it shows them you guys made the effort, that it is a genuine ongoing relationship, that he regards you with the same respect and intent that he would have shown had you been Moroccan, and that his family accepts you and welcomes you. If they see this, and you have submitted everything required, and he passes his medical/police/security/background clearances and he demonstrates his good intent in his interview, is able to answer all their questions, they would have no reason to reject your application.
If on the other hand you go ahead as currently planned, apply and its rejected (high probability) you are looking at an appeal which on average can take about 2 years or reapplying which would be another year and would mean going through the whole process again. Keep in mind, when re-applying you will have to have something additional to convince them or it will be rejected for the same reasons.
And sorry I just caught that you said you are surprising him? As in showing up unannounced?! Not a good idea. If you are determined to get married, he needs time to do a bunch of preparing on his end, getting his own documents in order, discussing with family, figuring out logistics of where you will stay, etc.. Don't just show up please! Even if you don't get married this trip, just showing up could put him in a difficult predicament. As mentioned before faith and family most likely plays a big part in his world.