VBA implements Reference counting to clean the memory using a "Garbage Collector"
When you call a function, it doesn't matter whether this function is private or public. What matters is, if inside the function you use a global or a local variable for your object. In your case it looks like it's local.
Your local variable is thus only referenced in your function, so its reference counter = 1.
At the moment your variable becomes out-of-scope, ie when the function ends and returns the value, the reference counter of the object is decremented and becomes 0.
Although the object is still physically present in memory, it is not addressable anymore, becomes useless, and is therefore candidate for the garbage collector.
When you code Set theobject_inside_function = nothing
you are just explicitly decrementing the reference counter. So it is useless to do it inside your function because VBA will do it for you once the function will end.
You can also read this article, it's old but still breaking a lot of myths regarding variable cleaning in VB