Can the last 2 players in Texas Holdem agree to split the pot equally after the river without showing their hands. is this legal or ethical?
This is a form of collusion, and would not be permitted in many casinos or tournaments according to their rules.
A home-game or less-reputable operation may make its own rules that allow this, but it would be considered very dodgy.
Legality does not typically factor, though anywhere in which it matters, either the entire game is illegal anyway or the operation already has rules to ensure they comply with law and regulation.
I have never seen a poker room or tournament venue in Europe or the US where this would be legal according to the house rules or any version of the TDA rules or similar which may be in effect - the potential for collusion and other angle shooting is very high if it were allowed and for this reason amongst others, I would suggest it is also unethical.
The only way I can imagine a pot would be split between two players without a showdown would be if they both mucked their cards simultaneously, ensuring they were unrecoverable from the muck. In this situation, there would be little choice but to split the pot, but I would expect the players involved to be warned not to do this again, for the sake of the integrity of the game.
In a casual game amongst friends, I'm sure this might be something which happens, but it should still be agreed upon by all players up front to keep the playing field level. I would not play a game for money which allowed this to happen.
Each hand in Texas Holdem has players compete to win the pot, or the collection of chips being wagered in that game. Sometimes the pot will end up being split if the betting is extremely high and one player does not have as many chips as their opponents are betting. In this case multiple people can win a part of the pot, but there is still at least one loser in this situation.
There is no rule I am aware of that allows players in a hand to mutually agree to bow out of a hand, but depending on where you're playing this may be a house rule that has been agreed upon and in that case would be legal at the table it's being played at.
Ethics would involve whether or not all players are aware of this rule prior to the start of the game, and agreed to enforce it. If this rule was not brought up, or if not everyone agreed to play by this rule, then it would not be ethical for two players to support it.
In the general sense as each showdown between players is meant to have a loser, one (or more) of the players who are splitting the pot had a weaker hand than the other. In this case the winning player is voluntarily sharing his chips with the losing player, which is against the rules.