It sounds like you need to set up Exchange Hybrid although it's really not clear to me what you're actually doing.
What is the "secondary server?" How did all this work before you bought "MS accounts?" Where was the MX pointing before? When you say "Exchange server" are you talking about Exchange Online or onprem? Which server is rejecting with the relay error?
Regardless, you're going to need objects in the environment where the MX points that forward to the second location where the rest of the users are. In Exchange onprem/Online this would ideally be a MailUser object created by Azure AD Connect, but a Contact could suffice in certain setups.
And the second environment needs to trust the emails forwarding through the first or you'll have SPF failures.
But again, a proper Exchange Hybrid setup takes care of all of this.
I am working part time for a small company, they have about 40 employees that use the email everyday for work and recently they have acquired a MS account for 10 employees that use it mainly for teams with customers but also sharepoint, etc.
To buy an MS account for each of the 40 would be too expensive and necessary because the other 30 only really use email in the day to day work.
okay, so you've got 10 employees with MS licensing. They have e-mail addresses through their microsoft licensing, correct? Those e-mails go through an exchange server? (whether on-premises or exchange online, right?)
The other 30 employees have e-mail using...what, exactly? (What kind of mail server?)
Because that Microsoft doc is typically used to set up stuff like scan-to-email for copiers and although you can do other things with relays, knowing the precise setup (without the exact domain names, just use domain1.com, domain2.com or whatever) is important here in order to get the MX records and any relays pointing at the servers where the addresses reside.
554 does seem to indicate a configuration or permissions issue, but to go down that route, I'd need a little more info about the non-microsoft side of things.