This is the joint distribution of two order statistics from a sample of two.
You can find that in many books.
I think it's in Wackerly, I used to use Hogg and Craig.
since you only have two observations...
There are 2! ways this can happen.
Either Y1=X1 or Y1=X2.
The reason it's still a valid density is that we now have a restriction on the space.
The order statistics are dependent.