Try this.
Remove the fills from both shapes, although you don't have to do this, it will allow you to see what is going on under the rectangle
Select the rectangle and Copy it
Select both star and rectangle and do Path > Difference. This operation will consume the rectangle. This is normal, don't panic!
Do Edit > Paste in Place to get the rectangle back
This will create two separate paths that fit together exactly. If you need to combine them to one path, select both and do Path > Combine
For example
If you have multiple complex overlapping shapes, I posted an answer here with a possible solution that will probably work better, but I won't repeat it here.
If you need to delete redundant segments, select the segments using the Edit Paths by Nodes tool, and hit the Delete Segment button.

