I know this is a reaaaaally old post, but I stumbled on it while searching for some Domain Driven Design patterns and saw that this post could need another point of view not mentioned here for all the people who ask themselves OPs question:
Why is it considered OK to have an Id field in the domain entities?
Well, lets see what is considered an Entity:
Domain-driven design recognizes multiple kinds of models.
For example, an entity is an object defined not by its attributes, but
its identity.
Quote from https://en.wikipedia.org/wiki/Domain-driven_design
So if your Business Object is an Entity it has to have an id that is immutable and globally unique. That is why business entities need an Id.
On the other hand there are value objects, which by definition are identified by the values of their attributes.
So they do not need a distinct id.
So why do in many models people write Ids to all their business classes? Usually to save them in the database which leads us to completely different topic: Persistence.
And in this case OPs feeling that putting an id into every business class feels wrong is correct. It is just bad application architecture design that leaks implementation details (how to persist data) into the domain model (by using primary keys in business classes).
So my answer: There are a lot of Ids in business objects because people do not separate their domain from their implementation thus keep mixing both.
It is just bad application design. I personally think this comes from the heavy usage and misconceptions of the usage of ORMs. They make it easy to bring your database scheme to your OOP application but often people misuse it, might it be, because they do not know better or because it is just easier operate on the database objects given from an OR-mapper (the latter is often seen together with other common anti patterns like anemic domain model, mutable objects and / or spreading business logic across the application like putting it into controllers or even worse into the OR-mapping types).
So my answer to the question:
So why do in many models people write Ids to all their business classes?
Together with your statement:
My understanding of domain model is that it should contain only things related to the domain.
is as follows:
An id (as an Identity) is via definition mandatory for an Entity in DDD but must not be provided to value objects, whose identity is defined by their attributes.
And my advice for people struggling with DDD and OR-mappers (Hibernate, EntityFramework[Core], you name it):
Separate your Business Model from your Database Model. In fact these two correlate a lot, but they are definetly not the same.
Do not put business logic into your database model. Put it where it belongs: In methods of your Business Classes (which gives them behavior) or in your application services that operate on your business objects and use the OR-mapper as what it was meant for: mapping Data to OOP Objects. That also prevents the anemic domain model anti pattern. A good separation of business model and implementation makes it by the way possible to switch to another implementation.
Links and more information about DDD:
Vaugn Vernon - Domain-driven design distilled (ISBN-10: 0134434420; ISBN-13: 978-0134434421)
https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html
https://en.wikipedia.org/wiki/Domain-driven_design
https://en.wikipedia.org/wiki/Anemic_domain_model
https://www.yegor256.com/2014/12/01/orm-offensive-anti-pattern.html