The BaseID is the identifier for each "object". Be it actor, items, statics. It's always the same and unchanging. BaseID designate the dormant version of each objects, a blueprint so to speak.
The RefID on the other hand is an identifier assigned to each object once they get into the world.
For example, you can have a set of different NPC named "Guard". You want to populate an area and spawn 20 of them through
placeatme or similar. They will each have an unique RefID, but some will share the same BaseID. The important element is that quests refers to other NPC and objects by their RefID, and thus you cannot just spawn a clone of a NPC and call it done.
This is how Skyrim generates dungeons. They have pools of blueprints and then spawn and level different actors when you enter the place.