In many cases, the Border Gateway Protocol (BGP) best path algorithm is not completely understood, resulting in an incorrect judgement that BGP is not selecting the best path to place in the routing table.
BGP routers typically receives multiple paths to the same destination. The BGP best path algorithm decides which is the best path to install in the IP routing table and to use for forwarding traffic.
Assume that all received paths for a particular prefix are arranged in a list, similar to the output of the show ip bgp [longer-prefixes] command. Some paths received by the router are not considered candidates for the best path. Such paths typically do not have the valid flag in the output of the show ip bgp [longer-prefixes] command.